
import 'dart:convert';
import 'dart:async';
import 'package:flutter_trip/model/home_model.dart';
import 'package:http/http.dart' as http;

const HOME_URL = "http://www.devio.org/io/flutter_app/json/home_page.json";
///首页大接口
class HomeDao{
  static Future<HomeModel> fetch() async{
    var url = Uri.parse(HOME_URL);
    final response =await http.get(url);
    if(response.statusCode == 200){
      Utf8Decoder utf8decoder = Utf8Decoder();//修复中文乱码问题
      var result = json.decode(utf8decoder.convert(response.bodyBytes));
      return HomeModel.fromJson(result);
    }else{
      throw Exception("加载HomeJson失败");

    }
  }
}